import request from '@/utils/request'
import qs from 'qs' // 引入qs
import { menuList } from './config'

// 登录
export function login(data) {
  data = qs.stringify(data)
  return COMMON_COJNFIG.isUseLocalData
    ? new Promise((resolve, reject) => {
        resolve({
          message: '操作成功',
          channelNo:
            '4E1BBE298EF2021B22A73835DB2EED5CC960C4715E006A26ED56B80DE4C923377C0FC6416A7556B31BB1A8EE2BE04355',
          rtnCode: '0000',
          rtnTime: '2025-04-15 09:35:41:888',
          body: '68D9BED899CF31EDF43724F79D250EA3D20A8F2556D4280BD2936EF5973E872344D9C0258D770ADBF3F9F7E3589F731A',
          head: null,
        })
      })
    : request({
        url: '/access/userLogin',
        method: 'post',
        data,
      })
}

//获取验证码
export function checkCode(data) {
  return COMMON_COJNFIG.isUseLocalData
    ? new Promise((resolve, reject) => {
        resolve({
          message: '操作成功',
          channelNo:
            '4E1BBE298EF2021B22A73835DB2EED5CC960C4715E006A26ED56B80DE4C923377C0FC6416A7556B31BB1A8EE2BE04355',
          rtnCode: '0000',
          rtnTime: '2025-04-15 09:35:41:888',
          body: '68D9BED899CF31EDF43724F79D250EA3D20A8F2556D4280BD2936EF5973E872344D9C0258D770ADBF3F9F7E3589F731A',
          head: null,
        })
      })
    : request({
        url: `/access/checkCode`,
        method: 'get',
        params: data,
        responseType: 'blob',
      })
}

//获取用户信息
export function getInfo(token) {
  return request({
    url: '/access/queryCurrentUser',
    method: 'get',
    params: { token },
  })
}

// 获取菜单
export function queryMenu(data) {
  data = qs.stringify(data)
  return new Promise((resolve, reject) => {
    resolve(menuList())
  })
  //   return COMMON_COJNFIG.isUseLocalData
  //     ? new Promise((resolve, reject) => {
  //         resolve(menuList())
  //       })
  //     : request({
  //         url: '/access/queryMenu',
  //         method: 'post',
  //         data,
  //       })
}
